package annotation;

import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

@Anno(className="annotation.AnnoDemo",methodName="add")
public class AnnoReflectTest {
    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
        Class aClass = Class.forName("annotation.AnnoReflectTest");
        Anno annotation = (Anno) aClass.getAnnotation(Anno.class);
        System.out.println(annotation.className());
        System.out.println(annotation.methodName());

        Class aClass1 = Class.forName(annotation.className());
        Object o = aClass1.newInstance();
        Method method = aClass1.getMethod(annotation.methodName());
        method.invoke(o);
    }
}
